import { requestAjax } from "./config.js";
// 提交订单【同接口，但是旅行社相关功能后端还未处理完】
export const order_submit = (data) => {
  //处理旅行社参数
  const codeType = uni.getStorageSync("codeType");
  const travelId = uni.getStorageSync("travelId");
  const query =
    codeType == 1
      ? { ...data, travelAgencyId: travelId }
      : codeType == 2
      ? { ...data, travelStaffId: travelId }
      : data;
  return requestAjax("/api/v1/order/user/submitOrder", query, "POST");
};
// 创建支付
export const weixin_pay = (data) => {
  return requestAjax("/api/v1/payment/payTradeByUser", data, "POST");
};

// 通用-根据商户交易单号查询支付结果(SUCCESS：已支付/USERPAYING: 正在支付中，如输入密码等/FAIL：明确支付失败)
export const order_change_status = (data) => {
  return requestAjax(`/api/v1/payment/payTradeByStaffByOutTradeNo/${data.id}`, {}, "GET");
};

// 获取订单列表【同接口】
export const my_order_list = (data) => {
  return requestAjax("/api/v1/order/user/myOrderList", data, "GET");
};

// 获取订单详情【同接口】
export const my_order_detail = (data) => {
  return requestAjax(`/api/v1/order/user/detail/${data.id}`, {}, "GET");
};

// 售后单-apis    ->    移动端-申请售后单【/api/v1/afterSale/applyByUser】
export const order_afterSale = (data) => {
  return requestAjax("/api/v1/afterSale/applyByUser", data, "POST");
};
